package com.ysl.study.designpattern.createmode.singleton;

/**
 * 单例模式 懒汉模式 线程不安全
 * 解决线程安全问题：
 * 1.同步锁
 * 2.双重校验锁
 * 3.静态内部类
 * 4.枚举
 *
 * @author yangshanlin
 * @date 2023/2/16 18:12
 * @describe
 */
public class Singleton2 {
    private Singleton2(){}

    private static Singleton2 single = null;

    public static Singleton2 getInstance(){
        if(single == null){
            single = new Singleton2();
        }
        return single;
    }

}
